import { Inject } from '@angular/core';
import { Http } from '@angular/http';
import { Quote } from './../domain/quote';
import { Observable } from 'rxjs/Rx';
import { Injectable } from '@angular/core';

@Injectable()
export class QuotService {
    constructor(private http: Http, @Inject('BASE_CONFIG') private config) {}

    getQuote(): Observable<Quote> {
        const url = `${this.config.url}/quotes/${Math.floor(Math.random() * 10)}`;
        return this.http.get(url)
        .map(res => res.json() as Quote)
    }
}
